'''
Author: your name
Date: 2020-11-06 13:45:13
LastEditTime: 2020-11-06 13:54:44
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \python-study\djangoS\app01\app01\Views\queryByPK.py
'''
from django.shortcuts import render,HttpResponse
from Models.models import Book
from django.core import serializers

class QueryByPK():
    def queryByKey(request):
        books = Book.objects.filter(pk=4)
        print(serializers.serialize("json",books))
        print("//////////////////////////////////////")
        books = Book.objects.filter(publish='菜鸟出版社', price=300)
        print(books, type(books))  # QuerySet类型，类似于list。
        return HttpResponse(serializers.serialize("json", books))